<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentname</title>
  </head>

  <body>
    <div id="tmpl"></div>

    <script id="tmpl1" type="text/x-jquery-tmpl">
      <div style="margin-bottom:10px;">
        <span>${id}</span>
        <span style="margin-left:10px;">{{tmpl($data) '#tmpl2'}}</span>
      </div>
    </script>
    <!-- 解释：
    如上，在模板 tmpl1 内嵌入 模板 tmpl2，传入渲染 tmpl1 的数据 $data === users；
    tmpl2 内使使用的数据在这里时同一份数据；
  -->
    <script id="tmpl2" type="type/x-jquery-tmpl">
      {{each name}}${$value}  {{/each}}
    </script>

    <script
      type="text/javascript"
      src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"
    ></script>
    <script type="text/javascript" src="./9/jquery.tmpl.min.js"></script>
    <script>
      $(function () {
        var users = [
          { id: 'think8848', name: ['Joseph', 'Chan'] },
          { id: 'aCloud', name: ['Mary', 'Cheung'] },
        ]
        $('#tmpl1').tmpl(users).appendTo('#tmpl')
      })
    </script>
  </body>
</html>
